<template>
  <div class="app-container">
    <el-form ref="form" :model="form"  label-width="80px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="订单号" >
            <el-input v-model="form.orderSn" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="订单状态" >
            <el-select
              v-model="form.orderStatus"
              placeholder="订单状态"
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="停车场" >
            <el-input v-model="form.parkingLot"  maxlength="11" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="车场编码" >
            <el-input v-model="form.parkingLotCode"  maxlength="50" :disabled="true"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="车位" >
            <el-input v-model="form.parkingSpace" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="车牌号" >
            <el-input v-model="form.plateNumber" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="是否物业车位" >
            <el-select v-model="form.spaceProperty" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="离场时间" >
            <el-input v-model="form.leaveTime"  />
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">修改</el-button>
        <el-button @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getorderSn, getparkSpace,  getorder,delSys, updateOrder,  changeRoleStatus } from "@/api/park/park";

export default {
  name: "Park",
  props: [ "cpDatas"],
  data() {
    return {
      form: {
        id: '',
        orderSn: '',
        leaveTime: '',
        spaceProperty: '',
        plateNumber: '',
        parkingSpace: '',
        parkingLotCode: '',
        orderStatus: '',
        parkingLot: ''
      },
      options: [{
        value: 'N',
        label: '否'
      }, {
        value: 'Y',
        label: '是'
      },
      ],
      statusOptions: [],
    };
  },
  created() {
    this.getList();
    this.getDicts("sys_park_orderStatus").then(response => {
      this.statusOptions = response.data;
    });
  },
  methods: {
    /** 查询同步列表 */
    getList() {
      this.loading = true;
      const orderSn = this.cpDatas.map(a =>a)
      getorderSn(orderSn).then(
        response => {
          this.form = response.data;
          console.log(this.form)
        }
      );
    },
    onSubmit(){
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            if (this.form.leaveTime =='') this.form.leaveTime=null
            console.log(this.form)
            updateOrder(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.$emit('clsoer');
            });
          }
        }
      });
    },
    // 取消按钮
    async cancel() {
      this.$emit('clsoer');
    },

  }
};
</script>
